Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add previous_page and next_page methods to paginator #1611

Merged
merged 1 commit into from
Nov 15, 2021
Merged

Add previous_page and next_page methods to paginator #1611

merged 1 commit into from
Nov 15, 2021

Conversation

wout
Copy link
Contributor

@wout wout commented Nov 13, 2021

Purpose

Adds previous_page and next_page methods to Lucky::Paginator.

(Sorry for not opening an issue first, but this seems like such an obvious addition).

Description

Currently, there are only the path_to_next and path_to_previous methods, returning a path including all query params. There's no way to get the next/previous page number other than calculating it based on the values returned by the paginator.page and paginator.total methods.

I'm working on an API and I need pagination with the full url and without any additional query parameters that may be present. To build the url, I need the previous and next page numbers rather than the paths.

Checklist

  • - An issue already exists detailing the issue/or feature request that this PR fixes
  • - All specs are formatted with crystal tool format spec src
  • - Inline documentation has been added and/or updated
  • - Lucky builds on docker with ./script/setup
  • - All builds and specs pass on docker with ./script/test

Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants